﻿<%@ Page Title="Manage Service Categories" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeBehind="ManageServiceCategories.aspx.cs" Inherits="NIntegrate.Configuration.UI.ManageServiceCategories" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <h2>Manage Service Categories</h2>
    <div class="bottomhyperlink"><img alt="Add new service category" src="Images/plus.gif" /><asp:LinkButton 
            ID="btnShowAddNewPanel" runat="server" Text="Add new service category" 
            onclick="btnShowAddNewPanel_Click"></asp:LinkButton></div>
    <br />
    <asp:GridView CssClass="gridview"
        ID="gvServiceCategories" runat="server" 
        DataSourceID="dsServiceCategories"
        DataKeyNames="ServiceCategory_id"
        AllowSorting="true"
        AutoGenerateDeleteButton="true"
        AutoGenerateColumns="false"
        AutoGenerateEditButton="true" onrowcommand="gvServiceCategories_RowCommand">
        <Columns>
            <asp:TemplateField HeaderText="ServiceCategoryName" SortExpression="ServiceCategoryName">
                <ItemTemplate>
                    <%#Eval("ServiceCategoryName")%>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:TextBox ID="tbServiceCategoryName" runat="server" MaxLength="100" Text='<%#Bind("ServiceCategoryName") %>'></asp:TextBox>
                    <asp:RequiredFieldValidator ID="tbServiceCategoryNameRequired" runat="server"
                        ControlToValidate="tbServiceCategoryName" EnableClientScript="false"
                        ErrorMessage="Required"></asp:RequiredFieldValidator>
                </EditItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Services">
                <ItemTemplate>
                    <asp:LinkButton ID="btnViewServices" runat="server" Text="View" CommandName="Select" CommandArgument='<%# "ViewServices|" + Eval("ServiceCategory_id") %>'></asp:LinkButton>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
        <SelectedRowStyle BackColor="LightYellow" />
    </asp:GridView>
    <asp:Panel ID="panelBottom" runat="server" CssClass="panelBottom">
        <asp:DetailsView ID="dvAddServiceCategory" runat="server" Visible="false"
            DataSourceID="dsServiceCategories" DefaultMode="Insert"
            AutoGenerateRows="false"
            AutoGenerateInsertButton="true"
            CssClass="detailstable" onitemcommand="dvAddServiceCategory_ItemCommand" 
            oniteminserted="dvAddServiceCategory_ItemInserted">
            <Fields>
                <asp:TemplateField HeaderText="ServiceCategoryName">
                    <InsertItemTemplate>
                        <asp:TextBox ID="tbServiceCategoryName" runat="server" MaxLength="100" Text='<%#Bind("ServiceCategoryName") %>'></asp:TextBox>
                        <asp:RequiredFieldValidator ID="tbServiceCategoryNameRequired" runat="server"
                            ControlToValidate="tbServiceCategoryName" EnableClientScript="false"
                            ErrorMessage="Required"></asp:RequiredFieldValidator>
                    </InsertItemTemplate>
                </asp:TemplateField>
            </Fields>
        </asp:DetailsView>
        <asp:GridView CssClass="gridview" Visible="false"
            ID="gvServices" runat="server" 
            DataSourceID="dsServices"
            AllowSorting="true"
            AutoGenerateColumns="false">
            <Columns>
                <asp:BoundField HeaderText="ServiceName" DataField="ServiceName" SortExpression="ServiceName" />
                <asp:BoundField HeaderText="AppCode" DataField="AppCode" SortExpression="AppCode" />
            </Columns>
        </asp:GridView>
    </asp:Panel>
    <ni:QueryDataSource ID="dsServiceCategories" runat="server" UseLocalQueryService="true">
    </ni:QueryDataSource>
    <ni:QueryDataSource ID="dsServices" runat="server" UseLocalQueryService="true">
    </ni:QueryDataSource>    
</asp:Content>
